package
{
	
	import flash.display.Bitmap;
	import flash.display.StageAlign;
	
	import widget.common.utils.MyLog;
	import widget.dress.DressViewer;
	import widget.dress.enum.DressEnum;
	import widget.dress.manager.DressManager;
	import widget.dress.mode.DressModel;

	public class WidgetRoleDress extends WidgetMain{
		
		/**人物预加载显示图片*/
		[Embed(source = "assets/image/dress/loadingPlayer.png")]
		private var LoadingPlayer:Class;
		private var loadingPlayer:Bitmap = new LoadingPlayer();
		public function WidgetRoleDress()
		{
			super();
		}
		
		protected override function init():void
		{
			stage.align = StageAlign.TOP_LEFT;
		
			configPath = "resource/config/orderdinner.xml";
			addAvatar(DressEnum.APPEARANCE_USER_FEMALE);
		}
		
		protected override function parseConfigXML(xmlStr:String):void
		{
			
		}
		
		private function addAvatar(dressID:String) : void
		{
			var dressMode:DressModel = new DressModel();
			dressMode.dressID = dressID;
			MyLog.debug(dressMode.uid);
			
			var dressViewer:DressViewer = createViewer(dressMode);
			dressViewer.x = 200;
			dressViewer.y = 200;
			this.addChild(dressViewer);
		}
		
		private function createViewer(model : DressModel) : DressViewer {
			var viewer : DressViewer = new DressViewer();
			var bmp : Bitmap = new Bitmap(loadingPlayer.bitmapData);
			bmp.x = -10;
			bmp.y = 30;
			viewer.addDress(bmp);
				
			DressManager.getInstance().addDress(model,viewer);
			return viewer;
		}
	}
}